package com.cy.jt.net;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Nginx {
    public static void main(String[] args) throws Exception {
        ServerSocket server= new ServerSocket(10001);
        System.out.println("Nginx start ok");
        while (true){
            Socket socket= server.accept();//阻塞式方法(没有客户端连接时，线程)
            System.out.println("client"+socket);
            ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
            String content=in.readUTF();
            System.out.println("client say"+content);
            Socket tomcatClient = new Socket("127.0.0.1",9999);
            //获取输出流对象
            ObjectOutputStream out = new  ObjectOutputStream(socket.getOutputStream());
            //向对应的服务端写数据
            out.writeUTF(content);
            //关流
            out.flush();
        }
    }
}